package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.dto.NotificationDTO;
import com.qzsf.backend.service.NotificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/22 21:51 周五
 * @Email 1429278462@qq.com
 * @Remark 通知控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("messages")
public class NotificationController {
    @Autowired
    private NotificationService notificationService;


    /**
     * 给指定用户发送消息
     */
    @PostMapping("/sendToUser")
    public Result sendToUser(@RequestBody NotificationDTO notificationDTO) {
        return notificationService.sendToUser(notificationDTO);
    }

    /**
     * 给某活动已报名成功的用户发送消息
     */
    @PostMapping("/sendToEventUsers")
    public Result sendToEventUsers(@RequestBody NotificationDTO notificationDTO) {
        return notificationService.sendToEventUsers(notificationDTO);
    }

    @GetMapping("history")
    public Result getNotification(@RequestParam int pageNo, @RequestParam int pageSize){
        return notificationService.getNotification(pageNo, pageSize);
    }

    @GetMapping("count")
    public Result getUserMessageCount(){
        return notificationService.getMessageCount();
    }

    @GetMapping("user")
    public Result getUserMessage(){
        return notificationService.getUserMessage();
    }

    @GetMapping("read")
    public Result readUserMessage(){
        return notificationService.readUserMessage();
    }
}
